package com.wangyuhang.service.impl;

import com.wangyuhang.dao.userDao;
import com.wangyuhang.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class userServiceImpl implements userService {
    @Autowired
    private userDao dao;

    @Override
    public void change(String name1, String name2, int salary) {
        dao.reduce(salary,name2);
        int i=1/0;   /*此处有异常，没开启事务前，减钱操作执行，加钱操作失败  开启事务后，加钱操作失败，事务回滚，两人金钱额度不变*/
        dao.add(salary,name1);
    }
}
